package com.lsw.jgyf.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.lsw.Base.BaseHolder;
import com.lsw.Base.BaseSimpleAdapter;
import com.lsw.jgyf.R;
import com.lsw.jgyf.model.ScreenModel;

/**
 * Created by lsw on 2018/7/10.
 */

public class SelectionSpecificationsBrandAdapter extends BaseSimpleAdapter<ScreenModel.BrandListEntity> {
    public SelectionSpecificationsBrandAdapter(Context context) {
        super(context);
    }

    private int isseclect = 0;

    public void setIsseclect(int isseclect) {
        this.isseclect = isseclect;
        notifyDataSetChanged();
    }

    public int getIsseclect() {
        return isseclect;
    }

    @Override
    protected BaseHolder<ScreenModel.BrandListEntity> getHolder() {
        return new BaseHolder<ScreenModel.BrandListEntity>() {
            TextView text;

            @Override
            public void bindViews(View parentView) {
                text = parentView.findViewById(R.id.text);
            }

            @SuppressLint("NewApi")
            @Override
            public void bindData(ScreenModel.BrandListEntity item, int position) {
                if (position == isseclect) {
                    text.setBackground(context.getResources().getDrawable(R.drawable.round_login_5dp));
                } else {
                    text.setBackground(context.getResources().getDrawable(R.drawable.round_login_5dp_gray));
                }
                text.setText(item.getName());
            }
        };
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.item_selection_specifications;
    }
}
